home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club (Business) 1997 July / Software of the Month Club - Business (Volume 239) (July 1997).iso / pc / code / shared.dxr / 04472_Core Engine.ls < prev    next >
Encoding:
Text File  |  1996-02-21  |  9.2 KB  |  327 lines

  1. global gWorld, gStates, gOBJECTS, gHotRects, gScreenState, gCursorList, gTimerList, gHitMaps, gCursorPresent, gKeyRef, cNullCast, cNullQTmovie, NULLRECT, gSpritePropTypes, gQTproplist, cNUllCharmovie, sPICTSPRITE, sQTSPRITE, sCURSORSPRITE, sCPSprite, sQTCharSprite, gUnvObjects, gAngles, gLastCursor, gPlayingQT, gScreenWidth, gScreenHeight, gCurKeyList, gTransMovieName, gAnimationObjects, gDeathRow, gLastKeyList, gKeyFrameSound, gEnvironmentSound, gGlobal, gKeyFrameSoundMode, gHaveNavs, gNextEnvLetter, gNextDIRFile, gMIDIPlayTRUE, gInitalized, xNAVXOBJ, xCURXOBJ, gCPU, gfileSep, gRootPath, gHDpath, gXobjs, gXOBJPath, gCDpath, gCDName, gQTmovPath, gSoundPath
  2.  
  3. on MainLoop
  4.   SetCursor(the mouseH, the mouseV)
  5.   CallAnimEngine()
  6.   CallTheTimer()
  7.   serviceSound()
  8.   CheckMIDI()
  9.   go(the frame)
  10. end
  11.  
  12. on CheckMIDI
  13.   if gMIDIPlayTRUE = #false then
  14.     exit
  15.   end if
  16.   midiInterrupt()
  17. end
  18.  
  19. on SetCursor H, v
  20.   set aPoint to point(H, v)
  21.   set ObjRef to inHotSpot(aPoint)
  22.   if ObjRef <> #empty then
  23.     set thisCursor to getaProp(getaProp(gOBJECTS, ObjRef), #cursor)
  24.   else
  25.     if gHaveNavs <> #false then
  26.       set navRefNum to inNavSpot(H, v)
  27.       if navRefNum <> #empty then
  28.         set thisCursor to getAt(getaProp(gCursorList, #NAV), navRefNum)
  29.       else
  30.         set thisCursor to getaProp(gCursorList, #NullCursor)
  31.       end if
  32.     else
  33.       if gHaveNavs = #false then
  34.         set thisCursor to getaProp(gCursorList, #NullCursor)
  35.       end if
  36.     end if
  37.   end if
  38.   set GraphicCursor to CallCursorPresent(H, v)
  39.   if (thisCursor <> gLastCursor) and (GraphicCursor = #false) then
  40.     set gLastCursor to thisCursor
  41.     cursor(thisCursor)
  42.   end if
  43. end
  44.  
  45. on CallCursorPresent H, v
  46.   if gCursorPresent = #false then
  47.     return #false
  48.   end if
  49.   repeat with MAPlist in gHitMaps
  50.     set map to getaProp(MAPlist, #hitxobj)
  51.     set index to getaProp(getaProp(MAPlist, #INDEXLIST), map(mWhere, H, v))
  52.     if listp(index) and (gCursorPresent <> index) then
  53.       set ObjRef to getaProp(index, #RefName)
  54.       if getaProp(index, #do) = #rollOver then
  55.         CursorRollover(ObjRef)
  56.         set gCursorPresent to index
  57.         return #false
  58.       else
  59.         if getaProp(index, #do) = #cursor then
  60.           CursorGraphic(ObjRef, H, v)
  61.           set gCursorPresent to index
  62.           return #true
  63.         else
  64.           if getaProp(index, #do) = #Handler then
  65.             do(getaProp(getaProp(getaProp(gOBJECTS, ObjRef), #action), #rollOver))
  66.             set gCursorPresent to index
  67.             return #false
  68.           end if
  69.         end if
  70.       end if
  71.       set gCursorPresent to index
  72.       next repeat
  73.     end if
  74.     if gCursorPresent = index then
  75.       if getaProp(index, #do) = #cursor then
  76.         set the locH of sprite sCURSORSPRITE to H
  77.         set the locV of sprite sCURSORSPRITE to v
  78.         cursor(200)
  79.         return #true
  80.       end if
  81.       next repeat
  82.     end if
  83.     set the loc of sprite sCURSORSPRITE to point(-2000, -2000)
  84.     set the castNum of sprite sCURSORSPRITE to cNullCast
  85.     set gCursorPresent to #true
  86.     return #false
  87.   end repeat
  88. end
  89.  
  90. on CursorRollover ObjRef
  91.   set obj to getaProp(gOBJECTS, ObjRef)
  92.   set the loc of sprite sCURSORSPRITE to getaProp(obj, #loc)
  93.   set the castNum of sprite sCURSORSPRITE to getaProp(getaProp(obj, #cast), #rollOver)
  94. end
  95.  
  96. on CursorGraphic ObjRef, H, v
  97.   set obj to getaProp(gOBJECTS, ObjRef)
  98.   set the locH of sprite sCURSORSPRITE to H
  99.   set the locV of sprite sCURSORSPRITE to v
  100.   set the castNum of sprite sCURSORSPRITE to getaProp(getaProp(obj, #cast), #rollOver)
  101.   set gLastCursor to getaProp(getaProp(obj, #cast), #rollOver)
  102.   cursor(200)
  103. end
  104.  
  105. on doMouseDown
  106.   if the lastClick > 30 then
  107.     exit
  108.   end if
  109.   set H to the mouseH
  110.   set v to the mouseV
  111.   set aPoint to point(H, v)
  112.   set ObjRef to inHotSpot(aPoint)
  113.   if ObjRef <> #empty then
  114.     do(string(getaProp(getaProp(getaProp(gOBJECTS, ObjRef), #action), #down) & "(#" & ObjRef & ")"))
  115.   else
  116.     if gHaveNavs <> #false then
  117.       set navRefNum to inNavSpot(H, v)
  118.       if navRefNum <> #empty then
  119.         genExitKF(getAt(getaProp(gCurKeyList, #GoWhere), navRefNum))
  120.       end if
  121.     end if
  122.   end if
  123. end
  124.  
  125. on keyDown
  126.   doKeyDown()
  127. end
  128.  
  129. on doKeyDown
  130.   if the shiftDown and (gGlobal = 1) then
  131.     set theKey to the key
  132.     if (theKey = "m") or (theKey = "M") then
  133.       open(window (the pathName & "DEBUG" & gfileSep & "memMon"))
  134.     else
  135.       if (theKey = "s") or (theKey = "S") then
  136.         open(window (the pathName & "DEBUG" & gfileSep & "status"))
  137.       else
  138.         if (theKey = "p") or (theKey = "P") then
  139.           open(window (the pathName & "DEBUG" & gfileSep & "mockmsg3"))
  140.         end if
  141.       end if
  142.     end if
  143.   end if
  144. end
  145.  
  146. on UniquieID aList
  147.   set ID to count(aList)
  148.   set Match to #false
  149.   repeat while Match = #false
  150.     set ID to ID + 1
  151.     if voidp(getaProp(aList, ID)) then
  152.       set Match to #true
  153.     end if
  154.   end repeat
  155.   return ID
  156. end
  157.  
  158. on InittheTimer
  159.   startTimer()
  160.   set gTimerList to [:]
  161.   sort(gTimerList)
  162. end
  163.  
  164. on startTheTimer aStopTime, ActionatTime, ObjRef
  165.   set aStartTime to the timer
  166.   if voidp(aStopTime) then
  167.     return [#Start: aStartTime, #TimeRefNum: #empty]
  168.   else
  169.     if not voidp(ActionatTime) then
  170.       set EndTime to aStartTime + aStopTime
  171.       set ThisTimer to [#Start: aStartTime, #end: EndTime, #action: ActionatTime, #TimeRefNum: UniquieID(gTimerList)]
  172.       if not voidp(ObjRef) then
  173.         set obj to getaProp(gOBJECTS, ObjRef)
  174.         if voidp(getaProp(obj, #timer)) then
  175.           setaProp(obj, #timer, [:])
  176.         end if
  177.         set ThisTimer to [#Start: aStartTime, #end: EndTime, #action: ActionatTime, #TimeRefNum: the ticks]
  178.         setaProp(getaProp(obj, #timer), getaProp(ThisTimer, #TimeRefNum), ThisTimer)
  179.       end if
  180.       setaProp(gTimerList, getaProp(ThisTimer, #TimeRefNum), ThisTimer)
  181.       return ThisTimer
  182.     end if
  183.   end if
  184. end
  185.  
  186. on CallTheTimer
  187.   if count(gTimerList) > 0 then
  188.     TimertheCheck()
  189.   end if
  190. end
  191.  
  192. on TimertheCheck
  193.   set Expired to []
  194.   repeat with TimeList in gTimerList
  195.     if the timer > getaProp(TimeList, #end) then
  196.       add(Expired, TimeList)
  197.     end if
  198.   end repeat
  199.   if count(Expired) > 0 then
  200.     repeat with TimeList in Expired
  201.       ExecutetheTimer(TimeList)
  202.     end repeat
  203.   end if
  204. end
  205.  
  206. on CheckTimePassed TimeList
  207.   set aTime to the timer - getaProp(TimeList, #Start)
  208.   return aTime
  209. end
  210.  
  211. on ExecutetheTimer TimeList
  212.   DeletetheTimer(TimeList)
  213.   do(getaProp(TimeList, #action))
  214. end
  215.  
  216. on DeletetheTimer TimeList
  217.   deleteProp(gTimerList, getaProp(TimeList, #TimeRefNum))
  218. end
  219.  
  220. on inHotSpot2 H, v
  221.   set nHotr to count(gHotRects)
  222.   repeat with X = 1 to nHotr
  223.     set arefname to inThisSpot(H, v, getAt(gHotRects, X))
  224.     if arefname <> #empty then
  225.       return arefname
  226.     end if
  227.   end repeat
  228.   return #empty
  229. end
  230.  
  231. on inHotSpot aPoint
  232.   set howMany to count(gHotRects)
  233.   if howMany > 0 then
  234.     repeat with thisOBJ = howMany down to 1
  235.       set thisListValue to getAt(gHotRects, thisOBJ)
  236.       set rectValue to getaProp(thisListValue, #rect)
  237.       if not voidp(rectValue) then
  238.         if inside(aPoint, rectValue) then
  239.           return getaProp(thisListValue, #RefName)
  240.         end if
  241.       end if
  242.     end repeat
  243.   end if
  244.   return #empty
  245. end
  246.  
  247. on inNavSpot H, v
  248.   set Where to xNAVXOBJ(mWhere, H, v)
  249.   if Where > 0 then
  250.     if getAt(getaProp(gCurKeyList, #GoWhere), Where) <> #empty then
  251.       return Where
  252.     end if
  253.   end if
  254.   return #empty
  255. end
  256.  
  257. on inThisSpot H, v, aRectList
  258.   if inside(point(H, v), getaProp(aRectList, #rect)) then
  259.     return getaProp(aRectList, #RefName)
  260.   else
  261.     return #empty
  262.   end if
  263. end
  264.  
  265. on QTLOOP
  266.   if the movieRate of sprite sQTSPRITE then
  267.     go(the frame)
  268.   else
  269.     HideQTTrans()
  270.     go("KeyFrame")
  271.   end if
  272. end
  273.  
  274. on HideQTTrans
  275.   set the movieRate of sprite sQTSPRITE to 0
  276.   set the locV of sprite sQTSPRITE to 10000
  277.   updateStage()
  278. end
  279.  
  280. on ShowQTTrans
  281.   set the rect of sprite sQTSPRITE to rect(0, 0, 560, 336)
  282. end
  283.  
  284. on CallAnimEngine
  285.   set activeObjectsCount to count(gAnimationObjects)
  286.   if activeObjectsCount > 0 then
  287.     repeat with objectNum = 1 to activeObjectsCount
  288.       stepAnimation(getAt(gAnimationObjects, objectNum))
  289.     end repeat
  290.     if count(gDeathRow) > 0 then
  291.       repeat with condemned in gDeathRow
  292.         death(getaProp(gAnimationObjects, condemned))
  293.       end repeat
  294.       set gDeathRow to []
  295.     end if
  296.   end if
  297. end
  298.  
  299. on ShiftgHotrects ObjRef
  300.   set obj to getaProp(gOBJECTS, ObjRef)
  301.   set the rect of sprite getaProp(obj, #spriteNum) to getaProp(obj, #Data)
  302.   updateStage()
  303.   set the rect of sprite getaProp(obj, #spriteNum) to NULLRECT
  304. end
  305.  
  306. on DoCharacterMovie ObjRef
  307.   set obj to getaProp(gOBJECTS, ObjRef)
  308.   setSoundState(#pause)
  309.   if getaProp(obj, #DisplayState) <> #OffScreen then
  310.     set the movieRate of sprite sQTCharSprite to 0
  311.     updateStage()
  312.     set TotalMov to count(getaProp(getaProp(obj, #cast), getaProp(obj, #DisplayState)))
  313.     setaProp(obj, #ConCount, getaProp(obj, #ConCount) + 1)
  314.     if TotalMov >= getaProp(obj, #ConCount) then
  315.       set aName to getAt(getaProp(getaProp(obj, #cast), getaProp(obj, #DisplayState)), getaProp(obj, #ConCount))
  316.     else
  317.       set aName to getAt(getaProp(getaProp(obj, #cast), getaProp(obj, #DisplayState)), TotalMov)
  318.     end if
  319.     set the fileName of cast cNUllCharmovie to string(gQTmovPath & aName)
  320.     updateStage()
  321.     set the loc of sprite sQTCharSprite to getaProp(obj, #loc)
  322.     set the movieTime of sprite sQTCharSprite to 0
  323.     set the movieRate of sprite sQTCharSprite to 1
  324.     updateStage()
  325.   end if
  326. end
  327.